{% extends 'base.html' %}

{% block content %}
<body>
  <form class="layui-form">
  <div class="layui-form-item" style="margin-top: 1%;">
      <div class="layui-input-inline" style="margin-left: 2%;">
        <input type="text" name="company" class="layui-input" lay-verify="company" placeholder="请输入目标企业关键字" >
      </div>
      <button type="submit" class="layui-btn" lay-submit="" lay-filter="search">查询架构</button>
      <button type="submit" class="layui-btn" lay-submit="" lay-filter="search_dom">查询域名</button>
      <!-- <p>不用设置Cookie了，取消了三级单位查询，如有需要请自行输入二级单位去查询三级单位</p> -->
      <!-- <a class="layui-btn" onclick="xadmin.open('设置Cookie',`{{ url_for('admin.cookie_edit') }}`,600,510)">设置Cookie</a> -->
  </div>
  </form>

  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>组织架构</legend>
  </fieldset>
  
  <div  style="margin-left: 2%;width: 95%;height: auto;">
    <div class="layui-form layui-border-box layui-table-view" lay-filter="LAY-table-1" lay-id="test">
      <div class="layui-table-tool">
          <div class="layui-table-tool-temp"></div>
          <div class="layui-table-tool-self">
            <p style="color:cornflowerblue;float: left;"><b>[ 导出组织架构  ]</b></p>
              <div class="layui-inline" title="导出" lay-event="LAYTABLE_EXPORT" id="export_struct">
                <i class="export layui-icon layui-icon-export"></i>
              </div>
          </div>
      </div>
  </div>

    <table id="ora_struct" style="margin-top: -28px;"></table>
  </div>
  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>域名统计</legend>
  </fieldset>
  
  <div  style="margin-left: 2%;width: 95%;height: auto;">
    <div class="layui-form layui-border-box layui-table-view" lay-filter="LAY-table-1" lay-id="test">
      <div class="layui-table-tool">
          <div class="layui-table-tool-temp"></div>
          
          <div class="layui-table-tool-self">
            <p style="color:cornflowerblue;float: left;"><b>[ 导出域名  ]</b></p>
              <div class="layui-inline" title="导出" lay-event="LAYTABLE_EXPORT" id="export_struct">
                <i class="export_domain layui-icon layui-icon-export"></i>
              </div>
          </div>
      </div>
    <table id="domains" style="margin-top: -15px;"></table>
  </div>
  <hr/>

<script>
layui.use(['form','table'], function(){
  var form = layui.form,
  table = layui.table,
  flow = layui.flow;

  //自定义验证规则
  form.verify({company:[/\S/,'任务名称不能为空'],});
  //监听提交(查询按钮)
  form.on('submit(search)',function(data) {
    //发异步，把数据提交给服务端
    //console.log(data.field);
    var comp_name = data.field['company'];
 

    //渲染表格 (组织架构)
    var ins1=table.render({
      elem: '#ora_struct'
      ,id:'com'
      ,title:comp_name+'企业组织架构'
      ,loading: true
      ,height: 450
      ,url: '/enscan/getinfo' //数据接口
      ,method: "post"
      ,where: data.field
      ,cols: [[ //表头
      {field: 'index', title: '序号', width:60, fixed: 'left', type: 'numbers'}
      ,{field: 'company_name', title: '单位名称'}
      ,{field: 'website', title: '网站首页'}
      ,{field: 'email', title: '邮箱地址'}
      ,{field: 'tel_phone', title: '电话号码'}
      ,{field: 'level', title: '单位级别'}
      ,{field: 'regrate', title: '投资占比'}
      ,{field: 'hunit', title: '上级单位'}
    ]],
    done: function (res, curr, count) {
                comp=res.data;
            }
  });

  return false;
  });

  form.on('submit(search_dom)',function(data) {
    //发异步，把数据提交给服务端
    //console.log(data.field);
    var comp_name = data.field['company'];
 

    //渲染表格 (域名统计)
var ins2=table.render({
  elem: '#domains'
  ,id:'dom'
  ,title:comp_name+'一级域名统计'
  ,loading: true
  ,height: 450
  ,url: '/enscan/getdomains' //数据接口
  ,method: "post"
  ,where: data.field
  ,cols: [[ //表头
     {field: 'index', title: '序号', width:60, fixed: 'left', type: 'numbers'}
    ,{field: 'domain', title: '一级域名',fixed: 'left'}
    ,{field: 'domain_from', title: '数据来源'}
  ]],
  done: function (res, curr, count) {
              doma=res.data;
          }
});

  return false;
  });

  //导出按钮(组织架构)
$(".export").click(function(){table.exportFile('com',comp);});

 //导出按钮(域名)
 $(".export_domain").click(function(){table.exportFile('dom',doma);});


});
</script>
</body>
{% endblock %}